<template>
  <el-drawer
    v-model="visible"
    direction="bttm"
    size="100%"
    :show-close="false"
    :modal="false"
    custom-class="player-drawer"
  >
    <div class="drawer-content">
      <div class="header">
        <el-button circle @click="visible = false">
          <el-icon><ArrowDown /></el-icon>
        </el-button>
      </div>
      
      <div class="main">
        <div class="cover">
          <img 
            :src="currentSong?.picUrl" 
            :alt="currentSong?.name"
            :class="{ playing }"
          >
        </div>
        
        <div class="info">
          <h2>{{ currentSong?.name }}</h2>
          <p>{{ artists }}</p>
        </div>
        
        <div class="lyric-container">
          <lyric
            :lyric="lyric"
            :current-time="currentTime"
          />
        </div>
      </div>
    </div>
  </el-drawer>
</template>

<script setup lang="ts">
import { ref, computed } from 'vue'
import { storeToRefs } from 'pinia'
import { usePlayerStore } from '@/stores/player'
import Lyric from './Lyric.vue'

const visible = ref(false)
const store = usePlayerStore()
const { currentSong, playing, currentTime, lyric } = storeToRefs(store)

const artists = computed(() => {
  return currentSong.value?.artists.map(a => a.name).join('/')
})

defineExpose({
  open() {
    visible.value = true
  }
})
</script>

<style scoped lang="scss">
:deep(.player-drawer) {
  background: linear-gradient(to bottom, #fff, #f5f5f5);
  
  .el-drawer__body {
    padding: 0;
  }
}

.drawer-content {
  height: 100%;
  display: flex;
  flex-direction: column;
  
  .header {
    padding: 20px;
    text-align: center;
  }
  
  .main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 20px;
    
    .cover {
      width: 300px;
      height: 300px;
      margin-bottom: 30px;
      
      img {
        width: 100%;
        height: 100%;
        border-radius: 8px;
        box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
        
        &.playing {
          animation: rotate 20s linear infinite;
        }
      }
    }
    
    .info {
      text-align: center;
      margin-bottom: 30px;
      
      h2 {
        font-size: 24px;
        margin-bottom: 10px;
      }
      
      p {
        color: #666;
      }
    }
    
    .lyric-container {
      flex: 1;
      width: 100%;
      max-width: 800px;
    }
  }
}

@keyframes rotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}
</style> 